<?
	
if(isset($_POST['btnsubmit']))
{
	require("required/dbconnect.php");
	require("required/email.php");


	require_once('required/recaptchalib.php');
		$resp = recaptcha_check_answer ($captcha_key_private,
											$_SERVER["REMOTE_ADDR"],
											$_POST["recaptcha_challenge_field"],
											$_POST["recaptcha_response_field"]);
	if (!$resp->is_valid) 
	{
		header("Location:os_contactus2.php?c=3&verycode=$verycode");
		die();
		
	}
	
	
	
	$company_name=mysql_escape_string($_POST['company_name']);
	$contact_person=mysql_escape_string($_POST['contact_person']);
	$designation = $_POST['designation'] ;
	$tel=$_POST['tel'];
	$fax=$_POST['fax'];
	$email=$_POST['email'];
	$address=$_POST['address'];
	$message=$_POST['message'];
	$ip=$_SERVER [ 'REMOTE_ADDR' ];
	
	$get_info=mysql_query("select * from os_contactinfo where id=1");
	$i=mysql_fetch_array($get_info,MYSQL_ASSOC);
	
	$websitename_eng=$i['website_name'];
	$logo_url=$i['logo_url'];
	$os_url=$i['website'];
	$admin_email=$i["email_hidden"];
	
	$to="$admin_email"; //receiver email here
		
	//------------------------ get data -----------------------------------
	
	$subject=$websitename_eng." Enquiry";		
	
	
	//-----------------------------------Body begin----------------------------
	$body="
	<html>
	<head>
	<style type='text/css'>
	<!--
		html,body,td,th {
	font-family: tahoma;
	font-size: 11px;
	margin-top:0px;
	margin-bottom:0px;
	
	
	}
	-->
	</style>
	</head>
	<body>
	<table>
		<tr>
			<td colspan=3><strong>$websitename_eng Enquiry System</strong></td>
		</tr>
		
		<tr>
			<td>Contact person</td><td>:</td><td>$contact_person</td>
		</tr>
		<tr>
			<td>Designation</td><td>:</td><td>$designation</td>
		</tr>
		<tr>
			<td>Company Name</td><td>:</td><td>$company_name</td>
		</tr>
		<tr>
			<td>Tel</td><td>:</td><td>$tel</td>
		</tr>
		<tr>
			<td>Fax</td><td>:</td><td>$fax</td>
		</tr>
		<tr>
			<td>Email</td><td>:</td><td>$email</td>
		</tr>
		<tr  valign=top>
			<td>Address</td><td>:</td><td>".str_replace("\n","<br>",$address)."</td>
		</tr>
		<tr>
			<td>IP</td><td>:</td><td>$ip</td>
		</tr>
		<tr>
			<td>Submit Datetime</td><td>:</td><td>".date('Y-m-d H:i:s')."</td>
		</tr>
		<tr valign=top>
			<td>Message</td><td>:</td><td>".str_replace("\n","<br>",$message)."</td>
		</tr>
		
		
	</table>
	</body>
	</html>	"; 
//-------------------------------- end of body ---------------------------------

		
	
	if(email_send($body,$to,"",$subject,"",$i['email']))
	{
		$status="success";
	}else{
		$status="failed";
	}
	header("Location:os_contactus2.php?c=1&verycode=$verycode&status=$status");
	
}
else
{
	require("required/dbconnect.php");
	$_SESSION['pid']="contact_us";
	$title="Contact";
	require("required/share_function.php");
	require("required/header.php");
	
?>
<script type="text/javascript">
 
	function check(frm){
		if(document.frm.contact_person.value=="")
		{
			alert("Please enter contact person");
			document.frm.contact_person.focus();
			return false;
		}
		if(document.frm.tel.value=="")
		{
			alert("Please enter contact number");
			document.frm.tel.focus();
			return false;
		}
		if(document.frm.email.value=="")
		{
			alert("Please enter email");
			document.frm.email.focus();
			return false;
		}
		if(document.frm.email.value!="")
		{
		 	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		   	var address = document.frm.email.value;
		   	if(reg.test(address) == false) {
				alert("Invalid email");
				document.frm.email.focus();
				return false;
			 }
		}
		if(document.frm.verification_code.value=="")
		{
			alert("Please enter verification_code");
			document.frm.verification_code.focus();
			return false;
		}
		
	
	}
</script>	 
<table width="100%" cellpadding="10" cellspacing="0" style="background:url('images/bg_contactus.jpg') right bottom no-repeat">
	<tr>
        <Td class="page_title_bar" colspan="2">CONTACT US</Td>
    </tr>
    <tr>
        <td valign="top">
           
                  
           			<?
						$get_info=mysql_query("select * from os_contactinfo where id=1");
						$a=mysql_fetch_array($get_info,MYSQL_ASSOC);
					?>
                    <strong><?= $a['company_name'] ?></strong><br />
                    <?= $a['address1'] ?><br />
                    <?= $a['address2'] ?><br />
                    <?= $a['address3'] ?><br />
                    <br /><br />
                    Tel: <?= $a['contact_number'] ?><br />
                    Fax: <?= $a['fax'] ?><br />
                    Email: <?= $a['email'] ?><br />
             
        </td>
        <td>
        	<strong>You may send your enquiries by submitting the form below. 	</strong>	
			<FORM ACTION="<?= $_SERVER['PHP_SELF'] ?>" METHOD="POST" name="frm" onSubmit="return check(this);">
				<table width="100%" cellpadding="5">
					<TR> 
						<TD VALIGN="MIDDLE" class="insidetext">Name of Company</TD>
						<TD WIDTH="7" VALIGN="MIDDLE" class="insidetext">:</TD>
						<TD VALIGN="MIDDLE" class="insidetext"> <INPUT TYPE="TEXT" NAME="company_name" SIZE="25" MAXLENGTH="100" class="text">
						</TD>
						
					  </TR>
					
					  
					  <TR> 
						<TD VALIGN="MIDDLE" class="insidetext">Person to Contact</TD>
						<TD WIDTH="7" VALIGN="MIDDLE" class="insidetext">:</TD>
						<TD VALIGN="MIDDLE" class="insidetext"> <INPUT TYPE="TEXT" NAME="contact_person" SIZE="25" MAXLENGTH="100" class="text"></TD>
					  </TR>
					   <TR> 
						<TD VALIGN="MIDDLE" class="insidetext">Designation</TD>
						<TD WIDTH="7" VALIGN="MIDDLE" class="insidetext">:</TD>
						<TD VALIGN="MIDDLE" class="insidetext"> <INPUT TYPE="TEXT" NAME="designation" SIZE="25" MAXLENGTH="100" class="text"></TD>
					  </TR>
					  <TR> 
						<TD VALIGN="middle" class="insidetext">Telephone number</TD>
						<TD WIDTH="7" VALIGN="middle" class="insidetext">:</TD>
						<TD VALIGN="MIDDLE" class="insidetext"> <INPUT TYPE="TEXT" NAME="tel" SIZE="25" class="text">
						 </TD>
					  </TR>
					   <TR> 
						<TD VALIGN="middle" class="insidetext">Fax</TD>
						<TD WIDTH="7" VALIGN="middle" class="insidetext">:</TD>
						<TD VALIGN="MIDDLE" class="insidetext"> <INPUT TYPE="TEXT" NAME="fax" SIZE="25" class="text">
						 </TD>
					  </TR>
					  <TR> 
						<TD VALIGN="MIDDLE" class="insidetext">E-mail</TD>
						<TD WIDTH="7" VALIGN="MIDDLE" class="insidetext">:</TD>
						<TD VALIGN="MIDDLE" class="insidetext"> <INPUT TYPE="TEXT" NAME="email" SIZE="25" MAXLENGTH="60" class="text">
						</TD>
					  </TR>
					   <TR> 
						<TD VALIGN="TOP" class="insidetext">Address</TD>
						<TD WIDTH="7" VALIGN="TOP" class="insidetext">:</TD>
						<TD VALIGN="TOP" class="insidetext"> <TEXTAREA NAME="address" COLS="35" ROWS="4" class="text"></TEXTAREA> 
						</TD>
					  </TR>
					  <TR> 
						<TD VALIGN="TOP" class="insidetext">Comment/Query</TD>
						<TD WIDTH="7" VALIGN="TOP" class="insidetext">:</TD>
						<TD VALIGN="TOP" class="insidetext"> <TEXTAREA NAME="message" COLS="35" ROWS="4" class="text"></TEXTAREA> 
						</TD>
					  </TR>
					  <tr valign="top">
						<td valign="top">Verification code<font color="#FF0000">*</font></td><td>:</td><td>
                        <script>
						var RecaptchaOptions = {  
							theme : 'custom',  
							lang: 'en',  
							custom_theme_widget: 'divrecaptcha' //div enclosing widget elements  
						 };  
						</script>
                        
						<div id="divrecaptcha" style="display: none;">

                        <div id="controls"><a href="#" onclick="Recaptcha.reload(); ">Get
                        another Captcha</a> <br />
                        </div>
            
                        <div id="recaptcha_image"></div>
                        <!--Important-->
            
                        <p><input type="text" name="recaptcha_response_field"
                            id="recaptcha_response_field" /><!--Important--> <br />
                        <span class="recaptcha_only_if_image">Enter the words shown above
                        separated by space</span>
                        
                        </div>
            
                        <?
                        require_once('required/recaptchalib.php');
            
                        echo recaptcha_get_html($captcha_key_public);
                        ?>
                        </td>
					  </tr>
					  <TR> 
						<TD>&nbsp;</TD>
						<TD WIDTH="7">&nbsp;</TD>
						<TD><INPUT NAME="btnsubmit" TYPE="submit" class="button" VALUE="Submit"> 
						  <B> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</B> </TD>
					  </TR>

					
				</table>
				</form>
        </td>
    </tr>
</table>
<?
	} require("required/footer.php");
?>